#!/usr/bin/env python
# coding:utf8

import unittest
import os
from basis.basis_driver import BasisBrowser, BasisDriver
from config.text_config import open_turtle, open_tkinter
from pages.browse_page import BrowsePage
from pages.login_page import LoginPage

class WebTestLogin(unittest.TestCase,LoginPage):

    Adress = '192.168.1.195'
    BASIS_BROWSER = BasisBrowser.Chrome
    path = os.path.abspath(os.path.dirname(os.getcwd()))
    '''使用basis_driver'''
    def setUp(self):
        # self.URL = "http://" + self.Adress + ":8081/bi"

        self.URL = "http://www.shunyingglobal.cn/Account/Login"
        self.driver = BasisDriver(self.BASIS_BROWSER)
        self.driver.maximize_window()
        self.driver.implicitly_wait(20)
        self.base_url = self.URL
        self.LOGINPAGE = LoginPage(self.driver,self.base_url)   #实例化LoginPage作为局部变量时使用
        self.LOGINPAGE.open("")
        open_tkinter("/data/huozhan.gif",
                                 '\n -----------模拟用户浏览测试-----------\n',
                                     '''
    1、用户浏览货栈首页
    2、用户操作全部商品分类浏览商品
    3、用户操作导航栏浏览商品
    4、用户操作展示板块浏览商品
    5、用户操作浏览热门排行榜的商品
    6、用户浏览国家地区馆的商品
    7、用户浏览热门品牌的商品
    8、用户操作浏览foot信息栏
    9、用户浏览帮助中心（注：此项目需要改版）
                                         ''')
        LOGINPAGE = LoginPage(self.driver, self.base_url)
        LOGINPAGE.login('15020579521','123456')
        self.driver.sleep(2)

    def tearDown(self):
        self.driver.quit_browser()
        pass

    def test_1browse_page(self):
        fp = BrowsePage(self.driver,self.base_url)
        open_turtle("用户浏览首页导航栏",x=-150,y=50)
        # self.driver.open_tk("/data/huozhan.gif","测试线程")
        fp.first_sub_bar()

    def test_2browse_page(self):
        fp = BrowsePage(self.driver, self.base_url)
        open_turtle("用户浏览商品分类",x=-150,y=50)
        fp.browse_first_sort()

    def test_3browse_page(self):
        fp = BrowsePage(self.driver, self.base_url)
        open_turtle( "用户浏览商品子分类",x=-150,y=50)
        fp.browse_sub_bar()


    def test_4browse_page(self):
        fp = BrowsePage(self.driver, self.base_url)
        open_turtle("用户浏览国家地区馆",x=-150,y=50)
        fp.browse_country()


    def test_5browse_page(self):
        fp = BrowsePage(self.driver, self.base_url)
        open_turtle("用户浏览热门品牌",x=-150,y=50)
        fp.top_brand()



if __name__ == '__main__':
    unittest.main()